<form class="layui-form" method="post">
    <div class="layui-form-item" style="padding-top: 2%">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <if condition="$updateone['m_email']">
                <div class="layui-input layui-input80 " style="border: none">{$updateone['m_email']}</div>
                <else/>
                <input type="text" name="email" lay-verify="required|email" maxlength="64"  placeholder="请输入邮箱" autocomplete="off"  id="username" class="layui-input layui-input80">
            </if>
            <img src="__PUBLIC__/Images/help.gif" class="tips_img" title="邮箱注册之后不能修改">
        </div>
    </div>
    <div class="layui-form-item" style="padding-top: 2%">
        <label class="layui-form-label">团队名称</label>
        <div class="layui-input-block">
            <input type="text" name="teamname" lay-verify="teamname" placeholder="请输入团队名称" value=" <if condition="$updateone['t_name'] neq $updateone['m_email']"> {$updateone.t_name} </if> " autocomplete="off" id="teamname" class="layui-input layui-input80">
            <img src="__PUBLIC__/Images/help.gif" class="tips_img" title="团队名称不填写,默认管理员邮箱名">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">用户别名</label>
        <div class="layui-input-block">
            <input type="text" name="relname" lay-verify="username" placeholder="请输入用户别名" value="<if condition="$updateone['m_name'] neq $updateone['m_email']"> {$updateone.m_name} </if>" autocomplete="off" id="relname" class="layui-input layui-input80">
            <img src="__PUBLIC__/Images/help.gif" class="tips_img" title="用户别名不填写,默认管理员邮箱名">
        </div>
    </div>
    <if condition="$updateone['m_email']">
        <div class="layui-form-item">
            <label class="layui-form-label">用户状态</label>
            <div class="layui-input-block">
                <input type="checkbox" name="usersattus" lay-text="开启|关闭" <if condition="$updateone['m_status'] eq 1">checked</if> lay-skin="switch">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码重置</label>
            <div class="layui-input-block">
                <input type="checkbox" name="pwdreset" lay-text="yes|no" lay-skin="switch">
                <img src="__PUBLIC__/Images/help.gif" class="tips_img" title="重置密码为系统默认密码">
            </div>
        </div>
        <else/>
        <div class="layui-form-item" style="padding-top: 2%">
            <label class="layui-form-label">团队角色</label>
            <div class="layui-input-block">
                <select name="jioase" lay-verify="required"  lay-filter="pintai">
                    <option value="">请选择角色</option>
                    <volist name="jiaose" id="jiaose">
                        <option value="{$jiaose.group_id}">{$jiaose.group_name}</option>
                    </volist>
                </select>
                <img src="__PUBLIC__/Images/help.gif" class="tips_img" title="团队名称不填写,默认管理员邮箱名">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">登录密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" lay-verify="pass" maxlength="20" placeholder="请输入密码" autocomplete="off" id="pwd" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">重复密码</label>
            <div class="layui-input-inline">
                <input type="password" name="regPwd" lay-verify="regPwd" maxlength="20" placeholder="请再次输入密码" autocomplete="off" id="regPwd" class="layui-input">
            </div>
        </div>
    </if>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="user">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>

    form.render();
    form.verify({
        teamname: function(value){
            if(!new RegExp("^$|^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                return '团队名称不能有特殊字符';
            }else if(/(^\_)|(\__)|(\_+$)/.test(value)){
                return '用户名首尾不能出现下划线\'_\'';
            }else if(/^\d+\d+\d$/.test(value)){
                return '用户名不能全为数字';
            }
            return;
        },
        username: function(value){
            if(!new RegExp("^$|^[^(and|or|exec|insert|select|union|update|&&|count|*|%)]*$").test(value)){
                return '用户名不能有特殊字符';
            }else if(/(^\_)|(\__)|(\_+$)/.test(value)){
                return '用户名首尾不能出现下划线\'_\'';
            }
            return;
        },
        regPwd: function(value){
            var pwd = $("#pwd").val();
            if(!new RegExp(pwd).test(value)) {
                return '两次输入的密码不一致';
            }
            return;
        },
        pass: [
            /^[\S]{6,12}$/
            ,'密码必须6到12位，且不能出现空格'
        ],
    });
    form.on('submit(user)', function(data){
        var userInfo = data.field;
        var url = "__SELF__";
        $.post(url,userInfo,function(data){
            if(data.code == '4001'){
                layer.msg(data.msg,{icon: 5});
                return;
            }else if(data.code == '101'){
                layer.msg(data.msg, {
                    icon: 6,
                    time: 2000
                }, function(){
                    location.reload();
                });
            }
        });

        return false;
    });

</script>